<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qsgengine.cpp -->
  <title>QSGEngine 类 | Qt Quick 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtquick-index.html">Qt Quick 模块</a></td><td ><a href="qtquick-module.html">C++ 类</a></td><td >QSGEngine</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#public-types">公用类型</a></li>
<li class="level1"><a href="#public-functions">公用函数</a></li>
<li class="level1"><a href="#static-public-members">静态公用成员</a></li>
<li class="level1"><a href="#details">详细信息</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QSGEngine 类</h1>
<!-- $$$QSGEngine-brief -->
<p>The <a href="qsgengine.html">QSGEngine</a> class allows low level rendering of a scene graph. <a href="#details">更多...</a></p>
<!-- @@@QSGEngine -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign">头文件：</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QSGEngine&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += quick</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 5.4</td></tr><tr><td class="memItemLeft rightAlign topAlign">继承自：</td><td class="memItemRight bottomAlign"> <a href="../qtcore/qobject.html">QObject</a></td></tr></table></div><ul>
<li><a href="qsgengine-members.html">所有成员的列表，包括继承成员</a></li>
<li><a href="qsgengine-obsolete.html">废弃的成员</a></li>
</ul>
<a name="public-types"></a>
<h2 id="public-types">公用类型</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#CreateTextureOption-enum">CreateTextureOption</a></b> { TextureHasAlphaChannel, TextureOwnsGLTexture, TextureCanUseAtlas, TextureIsOpaque }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> flags </td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#CreateTextureOption-enum">CreateTextureOptions</a></b></td></tr>
</table></div>
<a name="public-functions"></a>
<h2 id="public-functions">公用函数</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#QSGEngine">QSGEngine</a></b>(QObject *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#dtor.QSGEngine">~QSGEngine</a></b>() override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSGImageNode *</td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#createImageNode">createImageNode</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSGNinePatchNode *</td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#createNinePatchNode">createNinePatchNode</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSGRectangleNode *</td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#createRectangleNode">createRectangleNode</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSGAbstractRenderer *</td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#createRenderer">createRenderer</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSGTexture *</td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#createTextureFromId">createTextureFromId</a></b>(uint <i>id</i>, const QSize &amp;<i>size</i>, QSGEngine::CreateTextureOptions <i>options</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSGTexture *</td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#createTextureFromImage">createTextureFromImage</a></b>(const QImage &amp;<i>image</i>, QSGEngine::CreateTextureOptions <i>options</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#initialize">initialize</a></b>(QOpenGLContext *<i>context</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#invalidate">invalidate</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSGRendererInterface *</td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#rendererInterface">rendererInterface</a></b>() const</td></tr>
</table></div>
<ul>
<li class="fn">31 个公用函数继承自<a href="../qtcore/qobject.html#public-functions">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h2 id="static-public-members">静态公用成员</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> const QMetaObject </td><td class="memItemRight bottomAlign"><b><a href="qsgengine.html#staticMetaObject-var">staticMetaObject</a></b></td></tr>
</table></div>
<ul>
<li class="fn">9 个静态公用成员继承自<a href="../qtcore/qobject.html#static-public-members">QObject</a></li>
</ul>
<h3>额外的继承成员</h3>
<ul>
<li class="fn">1 个属性继承自<a href="../qtcore/qobject.html#properties">QObject</a></li>
<li class="fn">1 个公用槽函数继承自<a href="../qtcore/qobject.html#public-slots">QObject</a></li>
<li class="fn">2 个信号继承自<a href="../qtcore/qobject.html#signals">QObject</a></li>
<li class="fn">9 个保护函数继承自<a href="../qtcore/qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QSGEngine-description -->
<div class="descr">
<h2 id="details">详细信息</h2>
<p>The <a href="qsgengine.html">QSGEngine</a> class allows low level rendering of a scene graph.</p>
<p>A <a href="qsgengine.html">QSGEngine</a> can be used to render a tree of <a href="qsgnode.html">QSGNode</a> directly on a <a href="../qtgui/qwindow.html">QWindow</a> or <a href="../qtgui/qopenglframebufferobject.html">QOpenGLFramebufferObject</a> without any integration with QML, <a href="qquickwindow.html">QQuickWindow</a> or <a href="qquickitem.html">QQuickItem</a> and the convenience that they provide.</p>
<p>This means that you must handle event propagation, animation timing, and node lifetime yourself.</p>
<p><b>Note: </b>This class is for very low level access to an independent scene graph. Most of the time you will instead want to subclass <a href="qquickitem.html">QQuickItem</a> and insert your <a href="qsgnode.html">QSGNode</a> in a normal <a href="qtquick-module.html">QtQuick</a> scene by overriding <a href="qquickitem.html#updatePaintNode">QQuickItem::updatePaintNode</a>().</p></div>
<p><b>请参考 </b><a href="qsgabstractrenderer.html">QSGAbstractRenderer</a>。</p>
<!-- @@@QSGEngine -->
<div class="types">
<h2>成员类型文档</h2>
<!-- $$$CreateTextureOption$$$TextureHasAlphaChannel$$$TextureOwnsGLTexture$$$TextureCanUseAtlas$$$TextureIsOpaque -->
<h3 class="flags" id="CreateTextureOption-enum"><a name="CreateTextureOption-enum"></a>enum QSGEngine::<span class="name">CreateTextureOption</span><br/>flags QSGEngine::<span class="name">CreateTextureOptions</span></h3>
<p>The CreateTextureOption enums are used to customize how a texture is wrapped.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QSGEngine::TextureHasAlphaChannel</code></td><td class="topAlign tblval"><code>0x0001</code></td><td class="topAlign">The texture has an alpha channel and should be drawn using blending.</td></tr>
<tr><td class="topAlign"><code>QSGEngine::TextureOwnsGLTexture</code></td><td class="topAlign tblval"><code>0x0004</code></td><td class="topAlign">The texture object owns the texture id and will delete the GL texture when the texture object is deleted.</td></tr>
<tr><td class="topAlign"><code>QSGEngine::TextureCanUseAtlas</code></td><td class="topAlign tblval"><code>0x0008</code></td><td class="topAlign">The image can be uploaded into a texture atlas.</td></tr>
<tr><td class="topAlign"><code>QSGEngine::TextureIsOpaque</code></td><td class="topAlign tblval"><code>0x0010</code></td><td class="topAlign">The texture object is opaque.</td></tr>
</table></div>
<p>The CreateTextureOptions type is a typedef for <a href="../qtcore/qflags.html">QFlags</a>&lt;CreateTextureOption&gt;. It stores an OR combination of CreateTextureOption values.</p>
<!-- @@@CreateTextureOption -->
</div>
<div class="func">
<h2>成员函数文档</h2>
<!-- $$$QSGEngine[overload1]$$$QSGEngineQObject* -->
<h3 class="fn" id="QSGEngine"><a name="QSGEngine"></a>QSGEngine::<span class="name">QSGEngine</span>(<span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = nullptr)</h3>
<p>Constructs a new <a href="qsgengine.html">QSGEngine</a> with its <i>parent</i></p>
<!-- @@@QSGEngine -->
<!-- $$$~QSGEngine[overload1]$$$~QSGEngine -->
<h3 class="fn" id="dtor.QSGEngine"><a name="dtor.QSGEngine"></a><code>[override virtual] </code>QSGEngine::<span class="name">~QSGEngine</span>()</h3>
<p>Destroys the engine</p>
<!-- @@@~QSGEngine -->
<!-- $$$createImageNode[overload1]$$$createImageNode -->
<h3 class="fn" id="createImageNode"><a name="createImageNode"></a><span class="type"><a href="qsgimagenode.html">QSGImageNode</a></span> *QSGEngine::<span class="name">createImageNode</span>() const</h3>
<p>Creates a simple image node. When the scenegraph is not initialized, the return value is null.</p>
<p>This is cross-backend alternative to constructing a QSGSimpleTextureNode directly.</p>
<p>该函数于Qt 5.8中引入。</p>
<p><b>请参考 </b><a href="qsgimagenode.html">QSGImageNode</a>。</p>
<!-- @@@createImageNode -->
<!-- $$$createNinePatchNode[overload1]$$$createNinePatchNode -->
<h3 class="fn" id="createNinePatchNode"><a name="createNinePatchNode"></a><span class="type">QSGNinePatchNode</span> *QSGEngine::<span class="name">createNinePatchNode</span>() const</h3>
<p>Creates a nine patch node. When the scenegraph is not initialized, the return value is null.</p>
<p>该函数于Qt 5.8中引入。</p>
<!-- @@@createNinePatchNode -->
<!-- $$$createRectangleNode[overload1]$$$createRectangleNode -->
<h3 class="fn" id="createRectangleNode"><a name="createRectangleNode"></a><span class="type"><a href="qsgrectanglenode.html">QSGRectangleNode</a></span> *QSGEngine::<span class="name">createRectangleNode</span>() const</h3>
<p>Creates a simple rectangle node. When the scenegraph is not initialized, the return value is null.</p>
<p>This is cross-backend alternative to constructing a QSGSimpleRectNode directly.</p>
<p>该函数于Qt 5.8中引入。</p>
<p><b>请参考 </b><a href="qsgrectanglenode.html">QSGRectangleNode</a>。</p>
<!-- @@@createRectangleNode -->
<!-- $$$createRenderer[overload1]$$$createRenderer -->
<h3 class="fn" id="createRenderer"><a name="createRenderer"></a><span class="type"><a href="qsgabstractrenderer.html">QSGAbstractRenderer</a></span> *QSGEngine::<span class="name">createRenderer</span>() const</h3>
<p>Returns a renderer that can be used to render a <a href="qsgnode.html">QSGNode</a> tree</p>
<p>You call <a href="qsgengine.html#initialize">initialize</a>() first with the <a href="../qtgui/qopenglcontext.html">QOpenGLContext</a> that you want to use with this renderer. This will return a null renderer otherwise.</p>
<!-- @@@createRenderer -->
<!-- $$$createTextureFromId[overload1]$$$createTextureFromIduintconstQSize&QSGEngine::CreateTextureOptions -->
<h3 class="fn" id="createTextureFromId"><a name="createTextureFromId"></a><span class="type"><a href="qsgtexture.html">QSGTexture</a></span> *QSGEngine::<span class="name">createTextureFromId</span>(<span class="type"><a href="../qtcore/qtglobal.html#uint-typedef">uint</a></span> <i>id</i>, const <span class="type"><a href="../qtcore/qsize.html">QSize</a></span> &amp;<i>size</i>, <span class="type"><a href="qsgengine.html#CreateTextureOption-enum">QSGEngine::CreateTextureOptions</a></span> <i>options</i>) const</h3>
<p>Creates a texture object that wraps the GL texture <i>id</i> uploaded with <i>size</i></p>
<p>Valid <i>options</i> are <a href="qsgengine.html#CreateTextureOption-enum">TextureHasAlphaChannel</a> and <a href="qsgengine.html#CreateTextureOption-enum">TextureOwnsGLTexture</a></p>
<p>The caller takes ownership of the texture object and the texture should only be used with this engine.</p>
<p><b>请参考 </b><a href="qsgengine.html#createTextureFromImage">createTextureFromImage</a>(), <a href="qsgsimpletexturenode.html#setOwnsTexture">QSGSimpleTextureNode::setOwnsTexture</a>(), 和 <a href="qquickwindow.html#createTextureFromId">QQuickWindow::createTextureFromId</a>()。</p>
<!-- @@@createTextureFromId -->
<!-- $$$createTextureFromImage[overload1]$$$createTextureFromImageconstQImage&QSGEngine::CreateTextureOptions -->
<h3 class="fn" id="createTextureFromImage"><a name="createTextureFromImage"></a><span class="type"><a href="qsgtexture.html">QSGTexture</a></span> *QSGEngine::<span class="name">createTextureFromImage</span>(const <span class="type"><a href="../qtgui/qimage.html">QImage</a></span> &amp;<i>image</i>, <span class="type"><a href="qsgengine.html#CreateTextureOption-enum">QSGEngine::CreateTextureOptions</a></span> <i>options</i>) const</h3>
<p>Creates a texture using the data of <i>image</i></p>
<p>Valid <i>options</i> are <a href="qsgengine.html#CreateTextureOption-enum">TextureCanUseAtlas</a> and <a href="qsgengine.html#CreateTextureOption-enum">TextureIsOpaque</a>.</p>
<p>The caller takes ownership of the texture and the texture should only be used with this engine.</p>
<p><b>请参考 </b><a href="qsgengine.html#createTextureFromId">createTextureFromId</a>(), <a href="qsgsimpletexturenode.html#setOwnsTexture">QSGSimpleTextureNode::setOwnsTexture</a>(), 和 <a href="qquickwindow.html#createTextureFromImage">QQuickWindow::createTextureFromImage</a>()。</p>
<!-- @@@createTextureFromImage -->
<!-- $$$initialize[overload1]$$$initializeQOpenGLContext* -->
<h3 class="fn" id="initialize"><a name="initialize"></a><span class="type">void</span> QSGEngine::<span class="name">initialize</span>(<span class="type"><a href="../qtgui/qopenglcontext.html">QOpenGLContext</a></span> *<i>context</i>)</h3>
<p>Initialize the engine with <i>context</i>.</p>
<p><b>Warning:</b> You have to make sure that you call <a href="../qtgui/qopenglcontext.html#makeCurrent">QOpenGLContext::makeCurrent</a>() on <i>context</i> before calling this.</p>
<!-- @@@initialize -->
<!-- $$$invalidate[overload1]$$$invalidate -->
<h3 class="fn" id="invalidate"><a name="invalidate"></a><span class="type">void</span> QSGEngine::<span class="name">invalidate</span>()</h3>
<p>Invalidate the engine releasing its resources</p>
<p>You will have to call <a href="qsgengine.html#initialize">initialize</a>() and <a href="qsgengine.html#createRenderer">createRenderer</a>() if you want to use it again.</p>
<!-- @@@invalidate -->
<!-- $$$rendererInterface[overload1]$$$rendererInterface -->
<h3 class="fn" id="rendererInterface"><a name="rendererInterface"></a><span class="type"><a href="qsgrendererinterface.html">QSGRendererInterface</a></span> *QSGEngine::<span class="name">rendererInterface</span>() const</h3>
<p>Returns the current renderer interface if there is one. Otherwise null is returned.</p>
<p>该函数于Qt 5.8中引入。</p>
<p><b>请参考 </b><a href="qsgrendernode.html">QSGRenderNode</a> 和 <a href="qsgrendererinterface.html">QSGRendererInterface</a>。</p>
<!-- @@@rendererInterface -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
